/**
 * \brief  RM root interface
 * \author Christian Helmuth
 * \date   2006-07-17
 */

/*
 * Copyright (C) 2006-2009 Christian Helmuth
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _CORE__INCLUDE__RM_ROOT_H_
#define _CORE__INCLUDE__RM_ROOT_H_

/* Genode */
#include <root/component.h>

/* Core */
#include <rm_session_component.h>

namespace Genode {

	class Rm_root : public Root_component<Rm_session_component>
	{
		private:

			Server_entrypoint      *_ds_ep;
			Server_entrypoint      *_thread_ep;
			Allocator              *_md_alloc;

			Pager_activation<4096>  _pager_thread;
			Pager_entrypoint        _pager_ep;

			addr_t                  _vm_start;
			size_t                  _vm_size;

		protected:

			Rm_session_component *_create_session(const char *args)
			{
				return new (md_alloc())
				       Rm_session_component( _ds_ep,
				                             _thread_ep,
				                             _md_alloc,
				                            &_pager_ep,
				                             _vm_start, _vm_size);
			}

		public:

			/**
			 * Constructor
			 *
			 * \param session_ep   entry point for managing RM session objects
			 * \param ds_ep        entry point for managing dataspaces
			 * \param thread_ep    entry point for managing threads
			 * \param md_alloc     meta data allocator to be used by root component
			 * \param vm_start     begin of virtual memory (default value)
			 * \param vm_size      size of virtual memory (default value)
			 */
			Rm_root(Server_entrypoint *session_ep,
			        Server_entrypoint *ds_ep,
			        Server_entrypoint *thread_ep,
			        Allocator         *md_alloc,
			        addr_t             vm_start,
			        size_t             vm_size)
			:
				Root_component<Rm_session_component>(session_ep, md_alloc),
				_ds_ep(ds_ep), _thread_ep(thread_ep), _md_alloc(md_alloc),
				_pager_thread(), _pager_ep(&_pager_thread),
				_vm_start(vm_start), _vm_size(vm_size) { }
	};
}

#endif /* _CORE__INCLUDE__RM_ROOT_H_ */
